<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <style type="text/css">
        body,
        html {
            width: 100%;
            height: 100%;
            margin: 0;
            font-family: "微软雅黑";
        }

        #allmap {
            height: 100vh;
            width: 100%;
        }

        #r-result {
            width: 100%;
        }

        @keyframes scale {
            0% {
                transform: scale(0);
                background: #ff0000;
            }
            10% {
                transform: scale(0.1);
                background: #ff1d1d;
            }
            20% {
                transform: scale(0.2);
                background: #ff3939;
            }
            30% {
                transform: scale(0.3);
                background: #ff5e5e
            }
            40% {
                transform: scale(0.4);
                background: #ff7d7d;
            }
            50% {
                transform: scale(0.5);
                background: #ff9c9c;
            }
            60% {
                transform: scale(0.6);
                background: #ffb3b3;
            }
            70% {
                transform: scale(0.7);
                background: #ffcece;
            }
            80% {
                transform: scale(0.8);
                background: #ffeeee;
            }
            90% {
                transform: scale(0.9);
                background: #fff2f2;
            }
            100% {
                transform: scale(1);
                background: #fff2f2;
            }
        }

        @keyframes scale1 {
            0% {
                transform: scale(0);
                background: #ff0000;
            }
            10% {
                transform: scale(0.1);
                background: #ff1d1d;
            }
            20% {
                transform: scale(0.2);
                background: #ff3939;
            }
            30% {
                transform: scale(0.3);
                background: #ff5e5e
            }
            40% {
                transform: scale(0.4);
                background: #ff7d7d;
            }
            50% {
                transform: scale(0.5);
                background: #ff9c9c;
            }
            60% {
                transform: scale(0.6);
                background: #ffb3b3;
            }
            70% {
                transform: scale(0.7);
                background: #ffcece;
            }
            80% {
                transform: scale(0.8);
                background: #ffeeee;
            }
            90% {
                transform: scale(0.9);
                background: #fff2f2;
            }
            100% {
                transform: scale(1);
                background: #fff2f2;
            }
        }

        .classScale {
            animation: scale 2s linear infinite normal;
        }

        .classScale1 {
            animation: scale1 2s 1s linear infinite normal;
        }
    </style>
    <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=qUKBm0MPk3yTcmCeIjz7xDjOkwoqrvKI"></script>
    <title>车辆实时位置</title>
</head>

<body>
<div id="allmap"></div>
<script type="text/javascript" th:inline="javascript">
    window.onload = function () {
        // 百度地图API功能
        map = new BMap.Map("allmap");
        var point = new BMap.Point([[${lng}]], [[${lat}]]);
        map.centerAndZoom(point, 19);
        var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
        var top_left_navigation = new BMap.NavigationControl();  //左上角，添加默认缩放平移控件
        map.addControl(top_left_control);
        map.addControl(top_left_navigation);

        const option = {
            position: point,
            offset: new BMap.Size(-100, -100),
        };

        const valueLabel = new BMap.Label(
            "<div class='classScale' : ''} style='display:flex; justify-content: center; align-items: center; width:200px;height:200px;border-radius:50%; opacity: 0.5;'></div></div><div class='classScale1' : ''} style='position:relative; top: -200px;width:200px;height:200px;border-radius:50%; opacity: 0.5;'>",
            option);
        valueLabel.setStyle({
            border: 'none',
            backgroundColor: 'RGBA(0,0,0,0)',
        });
        map.addOverlay(valueLabel);

        var opts = {
            position: point,    // 指定文本标注所在的地理位置
            offset: new BMap.Size(-120, -140)    //设置文本偏移量
        };
        var msg=[[${msg}]];
        var label = new BMap.Label(msg, opts);  // 创建文本标注对象
        // var label = new BMap.Label('车辆位置在这!', opts);  // 创建文本标注对象
        label.setStyle({
            color: 'red',
            fontSize: '20px',
            lineHeight: '30px',
            fontFamily: '微软雅黑'
        });

        map.addOverlay(label);

        var myIcon = new BMap.Icon("http://lbsyun.baidu.com/jsdemo/img/car.png", new BMap.Size(50, 30));
        // var myIcon = new BMap.Icon("http://lbsyun.baidu.com/jsdemo/img/fox.gif", new BMap.Size(300,157));
        var marker2 = new BMap.Marker(point, {icon: myIcon});  // 创建标注
        marker2.setRotation(90);
        map.addOverlay(marker2);              // 将标注添加到地图中
    }
</script>
</body>
</html>